<template>
	<view>
		<goods-list :goods="goodList"></goods-list>
		<view class="over" v-if="flag">
			------ 我是有底线的 ------
		</view>
	</view>
</template>

<script>
	import goods_list from '../../components/goods_list/goods_list.vue'
	export default {
		data() {
			return {
				goodList: [],
				pageIndex: 1,
				flag: false
			}
		},
		onLoad(){
			this.getGoodsList()
		},
		methods: {
			async getGoodsList(callback) {
				if(!this.flag){
					const res = await this.$httpRes({
						url:'api/getgoods?pageindex='+this.pageIndex,
					})
					if(res.data.message.length<10){
						this.flag = true
					}
					this.goodList= [...this.goodList,...res.data.message]
					res && callback && callback()
				}
				
			},
		},
		components:{
			'goods-list': goods_list
		},
		onReachBottom() {
			this.pageIndex++
			this.getGoodsList()
		},
		onPullDownRefresh() {
			this.pageIndex = 1
			this.goodList = []
			this.flag = false
			setTimeout(() =>{
				this.getGoodsList(() => {
					uni.stopPullDownRefresh()
				})
			}, 800)
		}
	}
</script>

<style>
.over{
	height: 90rpx;
	line-height: 90rpx;
	background-color: #eee;
	text-align: center;
	font-size: 24rpx;
}
</style>
